import { createI18n } from "vue-i18n";
import { getBrowserLang } from "@/utils";

// element-plus 的ui框架国际化语言配置
import zhCnLocale from "element-plus/es/locale/lang/zh-cn";
import enLocale from "element-plus/es/locale/lang/en";

import customZhCn from "./modules/zh-cn";
import customEn from "./modules/en";

// 定义语言国际化内容 zh-cn en
const messages = {
  [zhCnLocale.name]: {
    ...zhCnLocale,
    ...customZhCn
  },
  [enLocale.name]: {
    ...enLocale,
    ...customEn
  }
};

const i18n = createI18n({
  silentTranslationWarn: true,
  missingWarn: false,
  silentFallbackWarn: true,
  fallbackWarn: false,
  locale: getBrowserLang(),
  fallbackLocale: zhCnLocale.name,
  messages,
  legacy: false
});

export default i18n;
